const data = [
  { name: "js", price: 100 },
  { name: "mysql", price: 212 },
  { name: "vue.js", price: 98 }
];
class Lesson {
  constructor(data) {
    this.model = data;
  }
  get price() {
    return this.model.price;
  }
  get name() {
    return this.model.name;
  }
  //批量生成对象
  static createBatch(data) {
    return data.map((item) => new Lesson(item));
  }
  //价格最贵的课程
  static maxPrice(data) {
    return data.sort((a, b) => b.price - a.price)[0];
  }
  //课程价格统计
  static totalPrice(data) {
    return data.reduce((t, c) => {
      return t + c.price;
    }, 0);
  }
}
const lessons = Lesson.createBatch(data);
console.log(lessons);
console.log(Lesson.maxPrice(lessons).price);
console.log(Lesson.maxPrice(lessons).name);
console.log(Lesson.totalPrice(lessons));
